define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'store/order/index' + location.search,
                    add_url: 'store/order/add',
                    edit_url: 'store/order/edit',
                    del_url: 'store/order/del',
                    multi_url: 'store/order/multi',
                    import_url: 'store/order/import',
                    table: 'store_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'address_id', title: __('Address_id')},
                        {field: 'order_sn', title: __('Order_sn'), operate: 'LIKE'},
                        {field: 'order_status', title: __('Order_status')},
                        {field: 'aftersale_status', title: __('Aftersale_status')},
                        {field: 'consignee', title: __('Consignee'), operate: 'LIKE'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'address', title: __('Address'), operate: 'LIKE'},
                        {field: 'message', title: __('Message'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'goods_price', title: __('Goods_price'), operate:'BETWEEN'},
                        {field: 'freight_price', title: __('Freight_price'), operate:'BETWEEN'},
                        {field: 'coupon_price', title: __('Coupon_price'), operate:'BETWEEN'},
                        {field: 'order_price', title: __('Order_price'), operate:'BETWEEN'},
                        {field: 'actual_price', title: __('Actual_price'), operate:'BETWEEN'},
                        {field: 'pay_id', title: __('Pay_id'), operate: 'LIKE'},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'ship_sn', title: __('Ship_sn'), operate: 'LIKE'},
                        {field: 'ship_channel', title: __('Ship_channel'), operate: 'LIKE'},
                        {field: 'ship_time', title: __('Ship_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'refund_apply_time', title: __('Refund_apply_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'after_sales_type', title: __('After_sales_type'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'refund_amount', title: __('Refund_amount'), operate:'BETWEEN'},
                        {field: 'refund_type', title: __('Refund_type'), operate: 'LIKE'},
                        {field: 'refund_content', title: __('Refund_content'), operate: 'LIKE'},
                        {field: 'refund_time', title: __('Refund_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'lock_version', title: __('Lock_version'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'confirm_time', title: __('Confirm_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'comments', title: __('Comments')},
                        {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'store_id', title: __('Store_id')},
                        {field: 'product_type', title: __('Product_type')},
                        {field: 'lease_type', title: __('Lease_type'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'lease_term', title: __('Lease_term'), operate: 'LIKE'},
                        {field: 'license_plate', title: __('License_plate'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'zstart_time', title: __('Zstart_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'zend_time', title: __('Zend_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'order_number', title: __('Order_number')},
                        {field: 'estimated_time', title: __('Estimated_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'delivery_code', title: __('Delivery_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'return_code', title: __('Return_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'delivery_time', title: __('Delivery_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'frame_number', title: __('Frame_number'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'lease_city', title: __('Lease_city'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'lease_address', title: __('Lease_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'lease_mobile', title: __('Lease_mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'deposit', title: __('Deposit'), operate:'BETWEEN'},
                        {field: 'return_time', title: __('Return_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'p_status', title: __('P_status')},
                        {field: 'is_door', title: __('Is_door')},
                        {field: 'q_user_id', title: __('Q_user_id')},
                        {field: 'pickup_note_number', title: __('Pickup_note_number'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'deduction', title: __('Deduction'), operate:'BETWEEN'},
                        {field: 'commission', title: __('Commission'), operate:'BETWEEN'},
                        {field: 'is_overtime', title: __('Is_overtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'is_deduction', title: __('Is_deduction')},
                        {field: 'trailer_address', title: __('Trailer_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'store_name', title: __('Store_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'trailer_longitude', title: __('Trailer_longitude'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'trailer_latitude', title: __('Trailer_latitude'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user_location', title: __('User_location'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user_longitude', title: __('User_longitude'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user_latitude', title: __('User_latitude'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rider_status', title: __('Rider_status')},
                        {field: 'defective_vehicle_model', title: __('Defective_vehicle_model'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'order_acceptance_time', title: __('Order_acceptance_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'arrival_time_of_vehicle', title: __('Arrival_time_of_vehicle')},
                        {field: 'arrival_time_at_destination', title: __('Arrival_time_at_destination')},
                        {field: 'appeal_time', title: __('Appeal_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'reason_for_appeal', title: __('Reason_for_appeal'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'q_appeal_status', title: __('Q_appeal_status')},
                        {field: 'installation_fee', title: __('Installation_fee'), operate:'BETWEEN'},
                        {field: 'delivery_fee', title: __('Delivery_fee'), operate:'BETWEEN'},
                        {field: 'pickup_time', title: __('Pickup_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'deliveryd_time', title: __('Deliveryd_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'service_completion_time', title: __('Service_completion_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'unlock_type', title: __('Unlock_type'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
